const { listApi } = require('../../../api/services/enterpriseDangers/index')
const app = getApp()
//排查人员管理人员页面

Page({
  data: {
    params: { pageNum: 0, pageSize: 10, divideId: '' },
    listData: [],
    dataMore: true,
    value1: '',
    active: '',
    YHPC_Edit: null,
  },

  // 搜索框
  onChange(e) {
    this.setData({
      active: e.detail,
      'params.divideId': e.detail,
    })
  },

  // 列表信息
  handleDesc(event) {
    let { item } = event.currentTarget.dataset
    if (this.data.YHPC_Edit) {
      wx.navigateTo({ url: '/pages/company/checkList/checkList?comId=' + item.com_id + '&divideId=' + this.data.active })
    } else {
      wx.navigateTo({ url: '/pages/company/checkListRead/checkListRead?comId=' + item.com_id + '&divideId=' + this.data.active })
    }
  },

  //列表数据
  async getListData() {
    if (!this.data.dataMore) return
    this.data.params.pageNum++
    const res = await listApi(this.data.params)
    if (res.code != 200) {
      return app.toast(res.msg)
    }
    const newList = [...this.data.listData, ...res.rows]

    this.setData({
      listData: newList,
      dataMore: newList.length < res.total,
    })
  },

  onLoad: function (options) {
    this.getListData()
  },

  onShow: function () {
    if(wx.getStorageSync('YHPC_Edit')){
      wx.setNavigationBarTitle({
        title: '隐患整改',
      })
    }else{
      wx.setNavigationBarTitle({
        title: '隐患排查',
      })
    }
    this.setData({ YHPC_Edit: wx.getStorageSync('YHPC_Edit') })
  },
})
